package mysql

import (
	"fmt"
	beego "github.com/beego/beego/v2/server/web"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB

func InitMysql() {
	user, _ := beego.AppConfig.String("MysqlUser")
	password, _ := beego.AppConfig.String("MysqlPassword")
	host, _ := beego.AppConfig.String("MysqlHost")
	port, _ := beego.AppConfig.String("MysqlPort")
	name, _ := beego.AppConfig.String("MysqlDbName")
	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", user, password, host, port, name)
	DB, _ = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	//DB.AutoMigrate(new(User), new(Order))
}
